package com.qiankun.tang.ui.fragment.find;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.common.library.ui.fragment.BaseFragment;
import com.common.library.ui.view.adapter.SimpleFragmentAdapter;
import com.common.library.ui.view.pager.ViewPagerLineIndicator;
import com.qiankun.tang.R;

import java.util.ArrayList;
import java.util.List;

/**
 * @author txf
 * @Title
 * @package com.qiankun.video.ui.fragment
 * @date 2017/6/12 0012
 */

public class FindFragment extends BaseFragment implements View.OnClickListener {
    ViewPagerLineIndicator mViewPagerLineIndicator;
    ViewPager mViewPager;
    TextView mTitle;
    @Override
    protected View buildChildView() {
        return LayoutInflater.from(getContext()).inflate(R.layout.fragment_find,null);
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        mViewPagerLineIndicator =getViewById(R.id.fragment_find_ViewPagerLineIndicator);
        mViewPager=getViewById(R.id.fragment_find_ViewPager);
        mTitle=getViewById(R.id.fragment_base_title);
        getViewById(R.id.fragment_base_search).setOnClickListener(this);
        init();
    }
    private void init() {
        mViewPager.setOffscreenPageLimit(3);
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new HotFragment());
        fragments.add(new ClassifyFragment());
        fragments.add(new AuthorFragment());
        mViewPager.setAdapter(new SimpleFragmentAdapter(getChildFragmentManager(),fragments));

        mViewPagerLineIndicator.setTabVisibleCount(3);
        mViewPagerLineIndicator.setTabProperty(14, Color.parseColor("#444444"), Color.parseColor("#7f7f7f"),Color.parseColor("#444444"),30);
        List<String>titles = new ArrayList<>();
        titles.add("热门");  titles.add("分类");  titles.add("作者");
        mViewPagerLineIndicator.setTabItemTitles(titles);
        mViewPagerLineIndicator.setViewPager(mViewPager,0);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.fragment_base_search:
                //TODO 搜索点击
                break;
        }
    }
}
